<?php
/*
 * filename: list.php
 * author: xuguoyu
 * date: 2010/4/22
 * update:
 * description: 
 */

require_once 'cls/base.php';

$tpl = new Template('t');
$tpl->setFile ( "main", "main.html" );
$tpl->setFile("list", "list.html");
$tpl->setBlock ( "list", "block1", "block1s" );

$type = getNum(fget("type"), 0);
$search = fget("search");

if($type) $where = "where type={$type} ";// 显示分类条目
if($search) $where = "where caption like '%{$search}%' ";//搜索条件

$db = conn();
$sql = "select count(*) from item " . $where;
$rs=$db->query($sql, MYSQL_NUM);
$page_str = pageft($rs[0][0],10);
$sql = "select * from item " . $where . "order by id desc {$page_str['limit']}";
$rs=$db->query($sql, MYSQL_ASSOC);
if(!empty($rs))
	foreach($rs as $v){
		$tpl->setvar(array("id" => $v['id'],
						"time" => lostTimeStr($v['time']),
						"caption" => $v['caption'],
						"price" => $v['price']
				));
		$tpl->parse ( "block1s", "block1", true );
	}
$tpl->setvar("page_str", $page_str["str"]);

$db->close();

$tpl->parse('main_content', 'list');
$tpl->p("main");
?>